package com.leo.offer;

/**
 *
 * @author xuexiaolei
 * @version 2018年03月08日
 */
public class T16 {
    public static Node reverseNode(Node head){
        Node newHead = null, temp;
        while (head != null){
            temp = head;
            head = head.next;
            temp.next = newHead;
            newHead = temp;
        }
        return newHead;
    }

    public static void main(String[] args) {
        Node node = Node.createNode(new int[] {1, 2, 3, 4});
        Node node1 = reverseNode(node);
//        Node node1 = reverseNode(null); //空用例
        Node.printNode(node1);
    }
}
